/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef IR_ANNOTATIONS_H_
#define IR_ANNOTATIONS_H_

#include "ir/vector.h"
#include "lib/cstring.h"

namespace P4::IR {
class Expression;

namespace Annotations {
/// Add @name annotation if there is no annotation already set
[[nodiscard]] Vector<Annotation> maybeAddNameAnnotation(const Vector<Annotation> &annos,
                                                        cstring name);
/// Replaces @name annotation, if any. Otherwise - add the name annotation
[[nodiscard]] Vector<Annotation> setNameAnnotation(const Vector<Annotation> &annos, cstring name);
[[nodiscard]] Vector<Annotation> withoutNameAnnotation(const Vector<Annotation> &annos);

void addIfNew(Vector<Annotation> &annotations, cstring name, const Expression *expr,
              bool structured = false);
void addIfNew(Vector<Annotation> &annotations, const IR::Annotation *ann);
void addOrReplace(Vector<Annotation> &annotations, cstring name, const Expression *expr,
                  bool structured = false);
void addOrReplace(Vector<Annotation> &annotations, const IR::Annotation *ann);
}  // namespace Annotations

}  // namespace P4::IR

#endif  // IR_ANNOTATIONS_H_
